@extends('front.header')
@section('title','往期视频')
@section('red')
    <div class="nav">
        <ul class="nav_body">
            <li><a  href="/">首页</a></li>
            <li><a  class="current" href="/expert/lecture">名家讲堂</a></li>
            <li><a href="/expert/front-list">名家风采</a></li>
            <li><a  href="/video/show">往期视频</a></li>
        </ul>
    </div>
@endsection
@section('content')
    <div class="main">
        <div class="online">
            <div class="online_class">
                <div class="online_class_bg"><img src="/assets/images/last_time_bg.jpg" /></div>
                <div class="online_class_body">
                    @if(isset($zVideo[0]))
                        <!--会议进行中-->
                            <?php $video=$zVideo[0]?>
                        <input type="hidden" id="video" value="{{$zVideo[0]->video}}">
                        <div class="meeting">
                            <a href="javascript:void(show2())">
                                <img src="/assets/images/online_classing.png" />
                            </a>
                        </div>
                    @elseif(isset($qVideo[0]))
                            <?php $video=$qVideo[0]?>
                        <div class="before" >
                            <div class="last_time_big" >
                                <span class="time1"></span>
                                <span class="time2"></span>
                                <span class="time3"></span>
                                <span class="time4"></span>
                            </div>
                            <a class="class_href" href="#"></a>
                        </div>
                    @elseif(isset($oVideos[0]))
                        <!--会议结束-->
                            <?php $video=$oVideos[0]?>
                        <div class="end_title">会议已结束</div>
                    @else
                            <?php $video=''?>
                        <div class="end_title">暂时没有会议</div>
                    @endif
                    <?php
                    function curPageURL() {
                        $pageURL = 'http';
                        error_reporting(0);
                        if ($_SERVER["HTTPS"] == "on") {    // 如果是SSL加密则加上“s”
                            $pageURL .= "s";
                        }
                        $pageURL .= "://";
                        if ($_SERVER["SERVER_PORT"] != "80") {
                            $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
                        } else {
                            $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
                        }
                        return $pageURL;
                    }
                    if($video!='') {
                        include("./phpqrcode/phpqrcode.php");//引入库文件
                        function getQRcode($data, $outfile)
                        {
                            $Qrcode = new QRcode();
                            $Qrcode->png($data, $outfile, 'L', 10);//前两个参数：文字（二维码的内容） 输出路径
                        }
                        $data = curPageURL();
                        $outfile = './assets/images/shouye.png';
                        getQRcode($data, $outfile);
                    }
                    ?>
                        @if(isset($qVideo[0]))
                        <div class="online_export_box">
                            <div class="online_export_bg"></div>
                            <div class="online_export clearfix">
                                <div class="online_export_ship">
                                    <div class="online_export_img">
                                        <a href="/expert/front-list-detail/{{$video->connection[0]->id}}"><img src="{{$video->connection[0]->photo}}" /></a>
                                    </div>
                                    <div class="online_export_txt">
                                        <p>专家：{{$video->connection[0]->name}}  {{$video->connection[0]->position}}</p>
                                        <p>医院：{{$video->connection[0]->hospital}}</p>
                                        <p>科室：{{$video->connection[0]->department}}</p>
                                        <p>职称：{{$video->connection[0]->position}}</p>
                                    </div>
                                </div>

                                <!--课程简介-->
                                <div class="online_export_ship border_left">
                                    <div class="online_export_intro">
                                        <p><b>课程简介</b></p>
                                        <p>{!! $video->content !!}</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        @endif

                </div>
                @if(isset($qVideo[0])||isset($zVideo[0]))
                    <div class="online_class_share">
                        <span>分享到：</span>
                        <a href="javascript:void(show())"><img src="/assets/images/icon_weixin.jpg" /></a>
                    </div>
                @endif
            </div>
        </div>
    </div>
    <div class="shadow" id="shadow" style="display:none"></div>
    <div class="chat_pop" style="display:none" id="chat_pop">
        <div class="chat_pop_top"><a href="javascript:void(hide())" class="chat_pop_close"></a></div>
        <div class="chat_pop_body">
            <img src="/assets/images/shouye.png" />
            <p>使用微信扫一扫，并将网页分享给好友</p>
        </div>
    </div>
    <!-- 姓名输入弹出框 -->
    <div id="name_pop" class="export_pop" style="display:none">
        <div class="export_pop_top">
            <span>提示</span>
            <a href="javascript:hide2()" class="export_pop_close"></a>
        </div>
        <div class="export_pop_body">
            <input type="hidden" id="url" value="{{$zVideo[0]->url}}">
            <div>请输入您的姓名：</div>
            <div class="export_name_input"><input id="nick_name" type="text" /></div>
            <div class="export_name_submit"><input type="button" class="btn blue_btn" value="确定" onclick="join_meeting()"/></div>
        </div>
    </div>
    <script>
        function join_meeting() {
            var nick_name=$("#nick_name").val();
            var url=$("#url").val();
            if(nick_name=="") {
                alert("请输入姓名");
                return;
            }
            url=url+"?nickName="+nick_name;
            window.open(url);
        }
        var time1 = document.querySelector(".time1");
        var time2 = document.querySelector(".time2");
        var time3 = document.querySelector(".time3");
        var time4 = document.querySelector(".time4");
        //获取截止时间的时间戳（单位毫秒）
        var inputTime = +new Date("<?php if(isset($qVideo[0])) echo ($qVideo[0]->begin)?>");
        var outTime = +new Date("<?php if(isset($zVideo[0])) echo ($zVideo[0]->end)?>");
        //我们先调用countDown函数，可以避免在打开界面后停一秒后才开始倒计时
        countDown();
        //定时器 每隔一秒变化一次
        setInterval(countDown, 1000);
        function countDown() {
            //获取当前时间的时间戳（单位毫秒）
            var nowTime = +new Date();
            //把剩余时间毫秒数转化为秒
            var times = (inputTime - nowTime) / 1000;
            var timess = (outTime - nowTime) / 1000;
            //计算小时数 转化为整数
            if(parseInt(times)>=0) {
                var d = parseInt(times / 60 / 60 / 24);
                //如果小时数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time1.innerHTML = d;
                var h = parseInt(times / 60 / 60 % 24);
                //如果小时数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time2.innerHTML = h < 10 ? "0" + h : h;
                //计算分钟数 转化为整数
                var m = parseInt(times / 60 % 60);
                //如果分钟数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time3.innerHTML = m < 10 ? "0" + m : m;
                //计算描述 转化为整数
                var s = parseInt(times % 60);
                //如果秒钟数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time4.innerHTML = s < 10 ? "0" + s : s;
                if(parseInt(times) == 0) location.reload(1);
            }
            if(parseInt(timess)==0) location.reload(1);
        }
        function show2(){
            document.getElementById("shadow").style.display="";
            document.getElementById("name_pop").style.display="";
        }
        function show(){
            document.getElementById("shadow").style.display="";
            document.getElementById("chat_pop").style.display="";
        }
        function hide2(){
            document.getElementById("shadow").style.display="none";
            document.getElementById("name_pop").style.display="none";
        }
        function hide(){
            document.getElementById("shadow").style.display="none";
            document.getElementById("chat_pop").style.display="none";
        }
    </script>
@endsection
